package api

import (
	"gitee.com/chejiangyi/bsfgo/core/utils"
	"gitee.com/chejiangyi/bsfgo/demo/domain"
	"gitee.com/chejiangyi/bsfgo/demo/domain/auto_models"
	"gitee.com/chejiangyi/bsfgo/gin2/controller"
	"github.com/gin-gonic/gin"
)

type GormController struct {
	controller.BaseApiController
}

func (m *GormController) Test(c *gin.Context) {
	defer m.CatchJsonError(c)
	var users []auto_models.User
	domain.GormInstance.Where("id=?", "1").Find(&users)
	domain.GormInstance.Where("name LIKE ?", "%a%").Find(&users)
	domain.GormInstance.First("id=?", "1").Find(&users)
	var count int64
	domain.GormInstance.Model(&auto_models.User{}).Where("name LIKE ?", "%a%").Count(&count)
	utils.LogUtil.Info("count:%v", count)
	m.JsonSuccess(c, users)
}
